#include <xp/net/ether.h>
#include <xp/bas/stdio.h>
#include <xp/bas/string.h>

int xp_main (int argc, xp_char_t* argv[])
{
	xp_byte_t addr[XP_ETHER_LEN + 1];
	xp_char_t buf[100];

	if (argc != 2) {
		xp_fprintf (xp_stderr, 
			XP_TEXT("usage: %s ethernet_address\n"), argv[0]);
		return -1;
	}

	if (xp_ether_xaton (argv[1], xp_strlen(argv[1]), addr) == -1) {
		xp_fprintf (xp_stderr, 
			XP_TEXT("wrong ethernet address - %s\n"), argv[1]);
		return -1;
	}

	xp_ether_ntoa (addr, buf, xp_countof(buf));
	xp_printf (XP_TEXT("[%s]\n"), buf);

	if (xp_ether_aton (argv[1], addr) == -1) {
		xp_fprintf (xp_stderr, 
			XP_TEXT("wrong ethernet address - %s\n"), argv[1]);
		return -1;
	}

	xp_ether_ntoa (addr, buf, xp_countof(buf));
	xp_printf (XP_TEXT("[%s]\n"), buf);

	return 0;
}
